<template>
  <!-- 跟踪记录新增 -->
  <div>
    <FormPanel ref="addRecordForm" :isSubmitBtn="false" :list="formList" :cols="1"></FormPanel>
    <div
      :style="{
        textAlign: 'center'
      }"
    >
      <el-button type="primary" icon="el-icon-tickets" @click="confirmDialog">确定</el-button>
      <el-button icon="el-icon-refresh-left" @click="closeDialog">取消</el-button>
    </div>
  </div>
</template>

<script>
import moment from 'moment';
export default {
  name: 'addRecordModel',
  data() {
    return {
      formList: this.createFormList(),
      formDate: {}
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {},
  methods: {
    createFormList() {
      return [
        {
          type: 'DATE',
          label: '跟踪时间',
          fieldName: 'traceLogDate',
          initialValue: moment().format('YYYY-MM-DD'),
          valueFormat: 'yyyy-MM-dd'
        },
        {
          type: 'TEXT_AREA',
          label: '备注',
          fieldName: 'traceLogDesc',
          placeholder: '请输入'
        }
      ];
    },
    // 新增数据
    confirmDialog() {
      this.$confirm('是否确认确定?', '提示', {
        confirmButtonText: '确认',
        cancelButtonText: '取消',
        type: 'warning'
      })
        .then(() => {
          let newObj = {};
          this.formList.map(x => (newObj[x.fieldName] = x.initialValue));
          this.$emit('saveRecord', newObj);
        })
        .catch(() => {});
    },
    closeDialog() {
      this.$emit('close', false);
    }
  }
};
</script>
<style lang="less" scoped></style>
